import axios from 'axios';
import Nprogress from 'nprogress';


// 请求基地址
const baseURL = 'http://geek.itheima.net/v1_0';

// 创建axios实例
const notifyRequest = axios.create({
  baseURL,
  timeout: 10000,
});

// 请求拦截器
notifyRequest.interceptors.request.use((config) => {
  Nprogress.start();
  return config;
}, (error) => {
  return Promise.reject(error);
});

// 响应拦截器
notifyRequest.interceptors.response.use((response) => {
  Nprogress.done();
  return response.data;
}, (error) => {
  Nprogress.done();
  return Promise.reject(error);
});


export default notifyRequest;